function tabBox(){
	var width = $('.tabbox .content').width();
	$('.tabbox .content ul').width(width*$('.tabbox .content li').length+'px');
	$('.tabbox .content ul li').width(width+'px');
	$(".tabbox .tab a").mouseover(function(){
		$(this).addClass('on').siblings().removeClass('on');
		var index = $(this).index();
		number = index;
		var distance = -width*index;
		$('.tabbox .content ul').stop().animate({
			left:distance
		});
	});
	
	var auto = 1;  //等于1则自动切换，其他任意数字则不自动切换
	if(auto ==1){
		var number = 0;
		var maxNumber = $('.tabbox .tab a').length;
		function autotab(){
			number++;
			number == maxNumber? number = 0 : number;
			$('.tabbox .tab a:eq('+number+')').addClass('on').siblings().removeClass('on');
			var distance = -width*number;
			$('.tabbox .content ul').stop().animate({
				left:distance
			});
		}
		var tabChange = setInterval(autotab,30000);
		//鼠标悬停暂停切换
		$('.tabbox').mouseover(function(){
			clearInterval(tabChange);
		});
		$('.tabbox').mouseout(function(){
			tabChange = setInterval(autotab,10000);
		});
	  }  
}


function loadFiles(data, flag){
	$('#orgTab a').remove();
	$('#fileContent ul li').remove();
	 var content = '<a href="javascript:;" class="on">设施局</a>';
	 var fileHead = '<table style="width:95%;text-align:center;margin-top:5px;" border="1">'+
							'<thead>'+
							'<th>序号</th>'+
							'<th>操作</th>'+
							'<th>上传用户</th>'+
							'<th>文件名</th>'+
							'<th>文件大小</th>'+
							'<th>文件类型</th>'+
							'<th>上传日期</th>'+
						'</thead>'+
						'<tbody>'+
						'</tbody>'+
					'</table>';
	var tableContent = '<li id="public">'+fileHead+'</li>';
	 var orgs = data['orgs'];
	 var attData = data['attachments'];
	 for(var i=0;i<orgs.length;i=i+2){
		 content += '<a href="javascript:;">'+orgs[i+1]+'</a>';
		 tableContent += '<li id="'+orgs[i]+'">'+fileHead+'</li>';
	 }
	 //加载tab
	 $('#orgTab').append(content);
	 //加载tab对应的li
	 $('#fileContent ul').append(tableContent);
	 //将相应的文件加载到table中
	  for(var i=0;i<attData.length;i++){
		  var trCount = 0
		  var href ="";
		  if(attData[i].tableId != null){
			  count = $('#'+attData[i].tableId+' tr').length;
			  href ="filedown";
		  } else {
			  count = $('#public tr').length;
			  href ="download";
		  }
		  var tr ="<tr><td>"+count+"</td><td><a href='"+appConfig.contPath+"/attachment/"+href+".do?attId="+attData[i].id+"'>下载&nbsp;&nbsp;</a>";
		  if(flag && attData[i].tableId != null){
			  tr +="<a href='javascript:void(0);' onclick='del(\""+attData[i].id+"\");'>删除</a>";
		  }
		  tr +="</td><td>"+attData[i].uploadPerson+"</td>"+
			"<td>"+attData[i].upfileFileName+"</a></td><td>"+attData[i].size+"</td><td>"+attData[i].type+"</td><td>"+attData[i].createDate+"</td></tr>";
			if(attData[i].tableId != null){
				$('#'+attData[i].tableId+' tbody').append(tr);
			} else {
				$('#public tbody').append(tr);
			}
	  }
}

function loadStaticData(data){
	//加载统计数据和统计图
	 var dataTitles = data['dataTitles'];
	 var lineList = data['lineList'];
//	 //存放统计数据
//	 var mycars=new Array(3)
	if(lineList.length != 0){
		 var content = '<table style="width:95%;text-align:center;margin-top:5px;" border="1"><thead><tr><td></td>';
		 for(var i =0 ;i<lineList.length;i++){
			 content += '<td>'+lineList[i][0]+'</td>';
		 }
		 content += '<td>总计</td></tr></thead><tbody>'
		 for(var j=0;j<dataTitles.length;j++){
			 var result = 0;
			 content +='<tr><td>'+dataTitles[j]+'</td>';
			 for(var i =0 ;i<lineList.length;i++){
				 content += '<td>'+lineList[i][j+1]+'</td>'
				 result += parseFloat(lineList[i][j+1]);
			 }
			 content += '<td>'+result+'</td></tr>';
		 }
		 content += '</tbody></table>';
		 $('#dataStatic').append(content);
	} else{
		$('#dataStatic').append('<span style="color:red">暂无数据</span>')
	}
}


function del(id){
		var AjaxURL = appConfig.contPath + "/attachment/delete.do";
		$.jBox.confirm("确认要删掉该条信息吗？", '系统提示', function(v, h, f) {
			if (v == 'ok') {
				loading('正在提交，请稍等...');
				$.ajax({
					type : "POST",
					dataType : "json",
					url : AjaxURL,
					data : {
						attId : id
					},
					success : function(data) {
						$.jBox.tip("删除成功", 'info');
						setTimeout("$.jBox.closeTip()", 1000);
						window.location.reload();
					},
					error : function(data) {
					}
				});
			}
		}, {
			buttonsFocus : 1
		});
	}